home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / jazlib.arc / JZPUTKBD.C < prev    next >
Text File  |  1988-12-18  |  2KB  |  58 lines

  1. /*
  2. ┌────────────────────────────────────────────────────────────────────────────┐
  3. │jzputkbd.c                                     │
  4. │Put characters in the keyboard buffer.                      │
  5. │                                         │
  6. │Synopsis: jzputkbd("msc test.c/r");                                         │
  7. │                                         │
  8. │To put extended chars in the buffer, just preface the scan codes with         │
  9. │"\377". i.e to put the F1 key in the buffer you would use:                  │
  10. │   jzputkbd("\377\073");    (\377 is octal for 255, \073 is octal for 59)   │
  11. │                                         │
  12. │ Note: you must compile this routine with /Ze cuz of the far pointers         │
  13. │                                         │
  14. │ (C) JazSoft Software by Jack A. Zucker (301) 794-5950              │
  15. └────────────────────────────────────────────────────────────────────────────┘
  16. */
  17. #include <jaz.h>
  18. #define BUFADDR 0x1E
  19. #if DEBUG
  20.    char far *whead = (char far *) 0x0040001A;    /* head of key buffer */
  21.    char far *wtail = (char far *) 0x0040001C;    /* tail of key buffer */
  22.    int wlen,w;
  23. #endif
  24. jzputkbd(fstr)
  25. unsigned char *fstr;
  26. {
  27.  
  28.    #if ! DEBUG
  29.    char far *whead = (char far *) 0x0040001A;    /* head of key buffer */
  30.    char far *wtail = (char far *) 0x0040001C;    /* tail of key buffer */
  31.    int wlen,w;
  32.    #endif
  33.  
  34.    wlen = min(strlen(fstr),16);     /* buffer holds only 16 chars    */
  35.  
  36.    *whead = BUFADDR;            /* point to start of key buffer */
  37.  
  38.    *wtail = BUFADDR;            /* point to start of key buffer */
  39.  
  40.    for (w = 1 ; w <= wlen && *fstr ; w ++)
  41.      if (*fstr == 255)
  42.        if (*(fstr+1)) {
  43.      fstr ++;
  44.      *(wtail + (w << 1)) = 0;
  45.      *(wtail + (w << 1)+1) = *fstr++;
  46.      *wtail += 2;
  47.        }
  48.        else {
  49.      *(wtail + (w << 1)) = 255;
  50.      *wtail += 2;
  51.        }
  52.      else {
  53.        *(wtail + (w << 1)) = *fstr++;
  54.        *wtail += 2;
  55.      }
  56. }
  57.  
  58.